package com.zhiche.lisa.lspm.service.trailer;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.zhiche.lisa.core.supports.BaseException;
import com.zhiche.lisa.lspm.dao.model.trailer.TrailerInfo;
import com.zhiche.lisa.lspm.dao.model.trailer.bo.*;
import com.zhiche.lisa.lspm.vo.vehicle.TrailerBasicVO;
import com.zhiche.lisa.lspm.vo.vehicle.TrailerDetailVO;
import com.zhiche.lisa.lspm.vo.vehicle.TrailerInfoLineVO;

import java.util.List;

/**
 * 挂车 service
 * @since 2018-05-28
 * @author lbl
 */
public interface TrailerInfoService extends IService<TrailerInfo> {

    /**
     * 挂车列表
     * @param page
     * @return
     */
    Page<TrailerInfoLineVO> trailerInfoLine(Page<TrailerInfoLineBO> page,String authorization);


    /**
     * 获取认证的挂车列表
     * @param page
     * @return
     */
    Page<TrailerInfoLineVO> authedTrailerInfoLine(Page<TrailerInfoLineBO> page);

    /**
     * 添加挂车基础信息
     * @param modifyTrailerInfoBO
     */
    void addTrailerInfo(ModifyTrailerInfoBO modifyTrailerInfoBO) throws BaseException;
    void updateLicense(ModifyTrailerInfoBO modifyTrailerInfoBO);
    void deleteLicense(ModifyTrailerLicenseBO modifyTrailerLicenseBO);
    /**
     * 查询编辑信息
     * @param id
     * @return
     */
    ModifyTrailerInfoBO findModifyInfo(Long id);

    /**
     * 编辑挂车基础信息
     * @param modifyTrailerInfoBO
     */
    void modifyTrailerInfo(ModifyTrailerInfoBO modifyTrailerInfoBO) throws BaseException;


    /**
     * 获取承运商下的挂车
     * @param page
     * @return
     */
    Page<TrailerDetailVO> getTrailerByLsp(Page<TrailerDetailVO> page,String authorization);

    /**
     * 停用挂车
     * @param trailerIds
     */
    List<String> discontinuatTrailer(Long[] trailerIds) throws BaseException;

    /**
     * 启用挂车
     * @param trailerIds
     */
    List<String> enableTrailer(Long[] trailerIds) throws BaseException;


    /**
     * 根据承运商 id 批量更新状态
     * @param status
     * @param lspIdList
     */
    void batchUpdateStatusByLspId(Integer authStatus,Integer status, List<Long> lspIdList);

    /**
     * 根据承运商ID的得到牵引车
     * @param lspId
     * @return
     */
    List<TrailerInfo> getListsByLspId(Long lspId);

    void authTrailerToERP(Long trailerId, String authorization);

    /**
     * 根据挂车ID认证挂车
     * @param trailerIds
     */
    List<String> batchUpdateAuthStatusByIds(Long[] trailerIds, String authorization) throws BaseException;

    /**
     * 根据挂车ID取消认证挂车
     * @param trailerIds
     */
    void batchUpdateCancelAuthStatusByIds(Long[] trailerIds) throws BaseException;

    /**
     * 根据承运商 id 数组获取底下的所有挂车 id
     * @param lspIdList
     * @return
     */
    List<Long> selectIdByLspIds(List<Long> lspIdList);

    /**
     * 根据ID批量更新状态
     * @param authStatus
     * @param status
     * @param idList
     */
    void batchUpdateAuthStatusByIds(Integer authStatus, Integer status, List<Long> idList);

    /**
     * 更换牵引车
     * @return
     */
    Integer updateCarrier(Long id,Long carrierId);

    /**
     * 批量移除牵引车
     * @param id
     * @return
     */
    Integer batchCarrierNull(List<Long> id);


    /**
     * 更换承运商
     * @param carrierIds
     * @param lspId
     * @return
     */
    Boolean changeLsp(Long[] carrierIds,Long lspId,Integer isAllTransfer,String authorization) throws BaseException;

    /**
     * 得到可用挂车
     * @param ew
     * @return
     */
    List<TrailerCarrierBO> listUsableTrailer(Wrapper<TrailerCarrierBO> ew);

    /**
     * 通过ID批量删除挂车
     * @param trailerIds
     * @return
     */
    List<String> deleteByIds(Long[] trailerIds);


    /**
     * 根据司机和牵引车车牌获取挂车信息
     * @param driverId
     * @param plate
     * @return
     */
    String getTrailerInfoByDriverAndCarrier(Long driverId,String plate);

    /**
     *
     * @param driverId
     * @param plate
     * @param tailerPlate
     * @return
     */
    Boolean verifyTrailerInfoByCarrier(Long driverId,String plate,String tailerPlate);

    /**
     * 根据
     * @param carrierInfoId
     * @return
     */
    TrailerInfoBO selectByCarrierInfoId(Long carrierInfoId);

    /**
     * 挂车完善信息状态
     * @param trailerId
     * @param typeCode
     * @param subjectCode
     * @return
     */
    Boolean getTrailerStatus(Long trailerId,String typeCode,String subjectCode);

    /**
     * 更新挂车信息
     * @param trailerInfo
     * @return
     */
    TrailerInfo updateTrailer(TrailerInfo trailerInfo);

    /**
     * 获取挂车信息
     * @param trailerId
     * @return
     */
    TrailerBasicVO getTrailerInfoLine(Long trailerId);

    /**
     * 获取挂车与牵引车列表
     * @param page
     * @return
     */
    Page<TrailerCarrierBO> carrierTrailerList(Page<TrailerCarrierBO> page);

    /**
     * 更新挂车里的关联的承运商关系
     * @param trailerInfo
     */
    void updateLspInfo(TrailerInfo trailerInfo);
    /**
     * 根据id号，恢复指定司机的删除状态
     * @param ids
     * @return
     */
    List<String> updateDeleteStatus(List<Long> ids);

    List<TrailerInfo> selectListNoTenant(EntityWrapper<TrailerInfo> tlEW);

    TrailerInfo selectByIdNoTenant(Long trailerId);
}
